// EG4ActionInit.c -- implementation of the class
// Created: Jan. 26, 2019, transcribed by Asia SUN, asia.rabbit@163.com
// Last modified: Jan. 28, 2019, by Asia SUN

#include "EG4ActionInit.h"
#include "EG4PGAction.h"
#include "EG4StepAction.h"
#include "EG4TrackAction.h"
#include "EG4EventAction.h"
#include "EG4RunAction.h"

EG4ActionInit::EG4ActionInit(EG4ROOT *r) : G4VUserActionInitialization(),
fROOT(r), fUsingGun(0), fTargetZ(0.){}

EG4ActionInit::~EG4ActionInit(){}

void EG4ActionInit::BuildForMaster() const{
  SetUserAction(new EG4RunAction(fROOT));
} // end member function BuildForMaster

void EG4ActionInit::Build() const{
  // true: using G4PartcileGun; false: using GPS and macro commands
  EG4RunAction *runAction = new EG4RunAction(fROOT);
  EG4EventAction *eventAction = new EG4EventAction(runAction);
  EG4TrackAction *trackingAction = new EG4TrackAction(eventAction);
  SetUserAction(new EG4PGAction(fUsingGun));
  SetUserAction(new EG4StepAction());
  SetUserAction(trackingAction);
  SetUserAction(eventAction);
  SetUserAction(runAction);
} // end member function Build
